package com.example.springcloudribbonclient.config;


import com.netflix.loadbalancer.BestAvailableRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class MyConfig {

    @Bean
    @LoadBalanced   //使用负载均衡
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

//    @Bean
//    public RandomRule RandomRule() {
//        return new RandomRule();
//    }

    /**
     * 似乎策略并没有生效,需要之后查找原因
     * @return
     */
    @Bean
    public BestAvailableRule randomRule() {
        return new BestAvailableRule();
    }
}
